from typing import *


class Solution:

    def countWays(self, ranges: List[List[int]]) -> int:
        ranges.sort(key=lambda a: (a[0], -a[1]))
        mod = 1000000007
        ans = 1
        r = -1
        for a, b in ranges:
            if a > r:
                ans *= 2
                ans %= mod
                r = b
            else:
                r = max(r, b)
        return ans
